

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layuiAdmin 内容系统 - 文章列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/sys/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/sys/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">订单号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="orderNo" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">客户名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">订单状态</label>
                    <div class="layui-input-inline">
                        <select name="delivery_status" lay-search>
                            <option value="">请选择标签</option>
                            <option value="已发货">已发货</option>
                            <option value="已退货">已退货</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">日期范围</label>
                    <div class="layui-input-inline">
                        <input type="text" name="start_end" class="layui-input" id="start_end_time" placeholder=" - ">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="table_temp_id">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-list" data-type="batchdel">删除</button>
                <button class="layui-btn layuiadmin-btn-list" data-type="add">添加</button>
                <span class="layui-inline ">
                    <input type="text" placeholder="搜索..." id="table_temp_search_id" autocomplete="off" class="layui-input layui-input-search" onchange="dataObj.search()">
                </span>
                <button type="button" class="layui-btn" id="test3"><i class="layui-icon"></i>上传文件</button>
            </div>
            <table id="table_temp_id" lay-filter="table_temp_id"></table>
        </div>
    </div>
</div>
<script type="text/html" id="table-content-list">

</script>
<script src="/sys/layuiadmin/js/jquery.min.js"></script>
<script src="/sys/layuiadmin/layui/layui.all.js"></script>
<script src="/sys/layuiadmin/js/lx.js"></script>
<script src="../jea.js"></script>
<script>
    //指定允许上传的文件类型
    layui.upload.render({
        elem: '#test3'
        ,url: '/app/fileUpload'
        ,accept: 'file' //普通文件
        ,exts: 'csv' //只允许上传压缩文件
        ,done: function(res){
            if (lx.login(res)) {
                dataObj.search();
                layer.msg('上传成功!');
            }
        }
    });

    dataObj.table_temp.url = lx.wwwroot+'/app/list?method=shipmentList';
    dataObj.table_temp.cols=[[
        {type:"checkbox",fixed:"left"}
        ,{field:"orderNo",title:"订单号",width:130,sort:!0}
        ,{field:"name",title:"客户名",width:90,sort:!0}
        ,{field:"comm_name",title:"商品名",align:"center",width:150,sort:!0}
        ,{field:"quan",title:"数量",width:80,sort:!0}
        ,{field:"total",title:"金额",width:80,sort:!0}
//        ,{field:"order_status",title:"订单状态",align:"center",width:100,sort:!0}
        ,{field:"delivery_status",title:"发货状态",align:"center",width:100,sort:!0,templet:function (d) {
            if(d.delivery_status == '已退货'){
                return '<span style="color:#FF5722">已退货</span>'
            }else if(d.delivery_status == '已发货'){
                return '<span style="color:#5FB878">已发货</span>'
            }else{
                return '';
            }
        }}
        ,{field:"remark_sj",title:"商家备注",sort:!0,width:180,sort:!0}
        ,{field:"addTime",title:"下单时间",sort:!0,width:180,sort:!0}
        ,{field:"remark",title:"客户备注",sort:!0,width:180,sort:!0}
        ,{field:"phone",title:"手机号码",width:120,sort:!0}
        ,{field:"address",title:"收货人地址",width:200,sort:!0}
        ,{field:"type",title:"类型",align:"center",width:80,sort:!0}
        ,{field:"returnTime",title:"退货时间",sort:!0,width:180,sort:!0}
//        ,{field:"status",title:"状态",width:100,align:"center",t1:'有效',t2:'无效',templet:temp_fun.sex_func,sort:!0}
        ,{title:"操作",minWidth:200,align:"center",fixed:"right",templet:function (d) {
            return `<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                    ${d.delivery_status=='已发货'?
                    '<a class="layui-btn layui-bg-orange layui-btn-xs" lay-event="hh"><i class="layui-icon layui-icon-return"></i>换货</a>' +
                    '<a class="layui-btn layui-bg-orange layui-btn-xs" lay-event="th"><i class="layui-icon layui-icon-close"></i>退货</a>'
                    :d.delivery_status=='已退货'?'':
                    d.comm_name?
                    '<a class="layui-btn layui-bg-green layui-btn-xs" lay-event="fh"><i class="layui-icon layui-icon-release"></i>发货</a>'
                    :'<a class="layui-btn layui-bg-green layui-btn-xs" lay-event="fz"><i class="layui-icon layui-icon-add-1"></i>复制</a>' +
                    '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>'
                    }
                    `;
        }}
    ]];
    dataObj.del=function (data) {
        lx.ajax("app/del/shipment",dataObj.del_success,{lx_id:data.id});
    };
    dataObj.edit = function (data) {
        return 'edit.html?id='+data.id;
    };
    //发货
    dataObj.fh_func=function (data) {
        layer.confirm('确定发货吗？', function(index) {
            lx.ajax("app/service?method=deliver_goods",dataObj.del_success,{id:data.id});
        });
    }
    //退货
    dataObj.th_func=function (data) {
        layer.msg('确定退货吗', {
            time: 20000, //20s后自动关闭
            btn: ['二次货', '未拆货', '取消']
            ,btn1:function(){
                lx.ajax("app/service?method=return_goods",dataObj.del_success,{id:data.id,ech:1});
            },btn2:function(){
                lx.ajax("app/service?method=return_goods",dataObj.del_success,{id:data.id});
            }
        });
    }
    //换货
    dataObj.hh_func=function (data) {
        layer.msg('确定换货吗', {
            time: 20000, //20s后自动关闭
            btn: ['二次货', '未拆货', '取消']
            ,btn1:function(){
                lx.ajax("app/service?method=exchange_goods",dataObj.del_success,{id:data.id,ech:1});
            },btn2:function(){
                lx.ajax("app/service?method=exchange_goods",dataObj.del_success,{id:data.id});
            }
        });
    }
    //复制
    dataObj.fz_func=function (data) {
        layer.confirm('确定复制吗？', function(index) {
            lx.ajax("app/service?method=copy_shipment",dataObj.del_success,{id:data.id});
        });
    }
    dataObj.add_content='edit.html';
    dataObj.delAll = function (checkData) {
        var ls = [];
        for(var i in checkData){
            var v = checkData[i];
            ls.push({lx_id:v.id});
        }
        layer.confirm('确定删除吗？', function(index) {
            lx.ajax("app/delAll/shipment",function () {
                layui.table.reload('table_temp_id');
                layer.msg('已删除');
            },{ls:JSON.stringify(ls)});
        });
    }
</script>
</body>
</html>
